#include<bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long LL;
int f[N]; 
int main()
{
    int n; cin >> n;
    for(int i = 1; i <= n; i++)
    {
    	cin >> f[i];
    	f[i] += f[i-1];
	}
	int q; cin >> q;
	while(q--)
	{
		int l , r ;
		cin >> l >> r;
		cout << f[r] - f[l-1] << endl;
	}
    return 0;
}